/*
Written by: Chris
http://www.pyroelectro.com

Tutorial: Servo Motor Control
http://www.pyroelectro.com/tutorials/servo_motor/index.html

November 17, 2007
*/

#include <p18f4520.h>
#include <delays.h>

#pragma config WDT = OFF // turns the watchdog timer off
//#pragma config PBADEN = OFF
#pragma config OSC = HS

void main(void)
{

int count=0;

TRISB = 0x00;
PORTB = 0x00;

	while(1)
	{

		for(count=0;count<50;count++)
		{  //far counter-clockwise
		PORTB = 0x01;
		Delay1KTCYx(10);
		PORTB = 0x00;
		Delay1KTCYx(90);
		}
			//middle
	for(count=0;count<50;count++)
		{
		PORTB = 0x01;
		Delay1KTCYx(7);
		Delay100TCYx(5);
		PORTB = 0x00;
		Delay1KTCYx(92);
		Delay100TCYx(5);
		}
		for(count=0;count<50;count++)
		{  //far counter-clockwise
		PORTB = 0x01;
		Delay1KTCYx(5);
		//Delay100TCYx(5);
		PORTB = 0x00;
		Delay1KTCYx(95);
		//Delay100TCYx(5);
		}
	;}
}